package com.vhall.component.controller.vote;

import com.vhall.component.controller.vote.facade.VoteApiFacade;
import com.vhall.component.entity.vote.vo.VoteDetailReqVO;
import com.vhall.component.entity.vote.vo.VoteDetailRspVO;
import com.vhall.component.entity.vote.vo.VoteInfoReqVO;
import com.vhall.component.entity.vote.vo.VoteInfoRspVO;
import com.vhall.component.entity.vote.vo.room.CheckSurveyReqVO;
import com.vhall.component.entity.vote.vo.room.CheckSurveyRspVO;
import com.vhall.component.framework.common.annotation.VhallComponent;
import com.vhall.component.plugin.common.annotation.ApiSignatureAuth;
import com.vhall.component.plugin.common.annotation.VssTokenAuth;
import com.vhall.component.plugin.common.support.VssToken;
import com.vhall.component.plugin.common.support.VssTokenThreadLocal;
import com.vhall.component.service.vote.VoteRoomService;
import com.vhall.component.service.vote.VoteService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


/**
 * 直播间内投票
 *
 * @author longzhen.gong
 * @date 2021/7/7 10:51
 */
@VhallComponent
@ApiSignatureAuth
@VssTokenAuth
public class VoteApiController implements VoteApiFacade {

    @Autowired
    private VoteService voteService;

    @Autowired
    private VoteRoomService voteRoomService;


    @Override
    public VoteInfoRspVO info(VoteInfoReqVO reqVO) {
        VssToken vssToken = VssTokenThreadLocal.getToken();
        return voteService.info(reqVO, vssToken.getThirdPartyUserId());
    }

    /**
     * 观众端调用 是否提交过投票
     *
     * @param reqVO
     * @return
     */
    @Override
    public CheckSurveyRspVO checkSurvey(CheckSurveyReqVO reqVO) {
        return voteRoomService.checkSurvey(reqVO);
    }

    @Override
    public List<VoteDetailRspVO> voteDetail(VoteDetailReqVO reqVO) {
        VssToken vssToken = VssTokenThreadLocal.getToken();
        return voteService.voteDetail(reqVO, vssToken.getThirdPartyUserId());
    }

    @Override
    public String answerCreate(String client, String id, String answer) {
        return voteService.answerCreate(client, id, answer);
    }


}
